//
//  NewMusicCollectionViewCell.m
//  LuckyRadio
//
//  Created by Mr、J on 15/11/17.
//  Copyright © 2015年 chenjun. All rights reserved.
//

#import "NewMusicCollectionViewCell.h"
#import <UIImageView+WebCache.h>


#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width

#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height

#define WIDTH_PRO(X) (X)*(SCREEN_WIDTH/375)

#define HEIGHT_PRO(Y) (Y)*(SCREEN_HEIGHT/667)

@implementation NewMusicCollectionViewCell
- (void)dealloc
{
    [_asiaNewSongModel release];
    [_image release];
    [_titleLabel release];
    [super dealloc];
}
-(instancetype)initWithFrame:(CGRect)frame
{
    if ([super initWithFrame:frame]) {
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews
{
    
    self.image = [[UIImageView alloc] init];
    [self.contentView addSubview:self.image];
    [_image release];
    
    self.titleLabel = [UILabel new];
    self.titleLabel.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:self.titleLabel];
    self.titleLabel.numberOfLines = 0;
    [_titleLabel release];
    
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.image.frame = CGRectMake(0, 0, (SCREEN_WIDTH - WIDTH_PRO(40)) / 3, (SCREEN_WIDTH - WIDTH_PRO(40)) / 3);
    self.titleLabel.frame = CGRectMake(0, self.image.frame.size.height + 10, (SCREEN_WIDTH - WIDTH_PRO(40)) / 3, HEIGHT_PRO(40));
}

-(void)setAsiaNewSongModel:(AsiaNewSongModel *)asiaNewSongModel{
    if (_asiaNewSongModel != asiaNewSongModel) {
        [_asiaNewSongModel release];
        _asiaNewSongModel = [asiaNewSongModel retain];
    }
    
    [self.image sd_setImageWithURL:[NSURL URLWithString:asiaNewSongModel.picUrl] placeholderImage:[UIImage imageNamed:@"Read_zhanwei"]];
    self.titleLabel.text = asiaNewSongModel.name;
}

@end
